using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace QuanLyNganHangDe.DAL.Models.Mapping
{
    public class DeInRaMap : EntityTypeConfiguration<DeInRa>
    {
        public DeInRaMap()
        {
            // Primary Key
            this.HasKey(t => t.MaDeThi);

            // Properties
            this.Property(t => t.MaDeThi)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.GioThi)
                .HasMaxLength(10);

            this.Property(t => t.NgayThi)
                .HasMaxLength(15);

            this.Property(t => t.MaDotThi)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.MaHocPhan)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.TenDangNhap)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.TenDeThi)
                .IsRequired()
                .HasMaxLength(400);

            // Table & Column Mappings
            this.ToTable("DeInRa");
            this.Property(t => t.MaDeThi).HasColumnName("MaDeThi");
            this.Property(t => t.LanThi).HasColumnName("LanThi");
            this.Property(t => t.GioThi).HasColumnName("GioThi");
            this.Property(t => t.NgayThi).HasColumnName("NgayThi");
            this.Property(t => t.ThoiGianLamBai).HasColumnName("ThoiGianLamBai");
            this.Property(t => t.DuocSuDungTaiLieu).HasColumnName("DuocSuDungTaiLieu");
            //this.Property(t => t.NoiDungDeThi).HasColumnName("NoiDungDeThi");
            //this.Property(t => t.NoiDungDapAn).HasColumnName("NoiDungDapAn");
            this.Property(t => t.MaDotThi).HasColumnName("MaDotThi");
            this.Property(t => t.MaHocPhan).HasColumnName("MaHocPhan");
            this.Property(t => t.TenDangNhap).HasColumnName("TenDangNhap");
            this.Property(t => t.TenDeThi).HasColumnName("TenDeThi");

            // Relationships
            this.HasRequired(t => t.NguoiSuDung)
                .WithMany(t => t.DeInRaCollection)
                .HasForeignKey(d => d.TenDangNhap);
            this.HasRequired(t => t.DotThi)
                .WithMany(t => t.DeInRaCollection)
                .HasForeignKey(d => d.MaDotThi);
            this.HasRequired(t => t.HocPhan)
                .WithMany(t => t.DeInRaCollection)
                .HasForeignKey(d => d.MaHocPhan);
        }
    }
}
